<template>
	<view class="container">
		<uni-section title="食物轮播图展示" sub-title="" type="line">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
				<swiper-item v-for="item in list">
					<view class="swiper-item">
						<img :src="'http://localhost:8090'+item.icon" style="width: 100%; height: 200px;">
					</view>
				</swiper-item>
			</swiper>
		</uni-section>
		<uni-section title="食物类别宫格展示" sub-title="" type="line">
			<uni-grid :column="3">
				<uni-grid-item v-for="item in lista">
					<view style="display: flex; flex-direction: column; margin-top: 60rpx; align-items: center;">
						<img :src="'http://localhost:8090'+item.icon" style="height: 100rpx;width: 100rpx;">
						<text>{{item.typename}}</text>
					</view>
				</uni-grid-item>
			</uni-grid>
		</uni-section>
		<uni-section title="食物列表展示(3条)" sub-title="" type="line">
				<uni-list>
					<uni-list-item :title="item.name" :to="'../fooddetail/fooddetail?id='+item.id" note="" :rightText="'￥'+item.price"
						:thumb="'http://localhost:8090'+item.icon" v-for="item in listb">
					</uni-list-item>
				</uni-list>
		</uni-section>
		<uni-section title="食物评论列表展示(3条)" sub-title="" type="line">
			<uni-list>
				<uni-list-item :title="item.comment" note="" :rightText="item.postdate" v-for="item in listc">
				</uni-list-item>
			</uni-list>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				lista: [],
				listb: [],
				listc: []
			}
		},
		methods: {

		},
		onLoad() {
			uni.request({
				url: 'http://localhost:8090/foodapp/foodSwiper/list',
				method: 'POST',
				data: {},
				success: res => {
					if (res.data.success) {
						this.list = res.data.list

					} else {

					}
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: 'http://localhost:8090/foodapp/foodType/list',
				method: 'POST',
				data: {},
				success: res => {
					if (res.data.success) {
						this.lista = res.data.list
					}
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: 'http://localhost:8090/foodapp/food/list',
				method: 'POST',
				data: {},
				success: res => {
					if (res.data.success) {
						this.listb = res.data.list
					} else {

					}
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: 'http://localhost:8090/foodapp/comment/list',
				method: 'POST',
				data: {},
				success: res => {
					if (res.data.success) {
						this.listc = res.data.list
					} else {

					}
				},
				fail: () => {},
				complete: () => {}
			});
		}
	}
</script>

<style>

</style>
